"""
简历管理URL配置
"""
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from . import views

# 创建主路由器
router = DefaultRouter()
router.register(r'resumes', views.ResumeViewSet, basename='resume')
router.register(r'templates', views.ResumeTemplateViewSet, basename='resume_template')

urlpatterns = [
    # ViewSet路由
    path('', include(router.urls)),

    # 简历子资源路由
    path('resumes/<int:resume_pk>/basic-info/', views.BasicInfoViewSet.as_view({
        'get': 'list',
        'post': 'create'
    }), name='resume-basic-info-list'),
    path('resumes/<int:resume_pk>/basic-info/<int:pk>/', views.BasicInfoViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'patch': 'partial_update',
        'delete': 'destroy'
    }), name='resume-basic-info-detail'),

    path('resumes/<int:resume_pk>/education/', views.EducationViewSet.as_view({
        'get': 'list',
        'post': 'create'
    }), name='resume-education-list'),
    path('resumes/<int:resume_pk>/education/<int:pk>/', views.EducationViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'patch': 'partial_update',
        'delete': 'destroy'
    }), name='resume-education-detail'),

    path('resumes/<int:resume_pk>/skills/', views.SkillViewSet.as_view({
        'get': 'list',
        'post': 'create'
    }), name='resume-skills-list'),
    path('resumes/<int:resume_pk>/skills/<int:pk>/', views.SkillViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'patch': 'partial_update',
        'delete': 'destroy'
    }), name='resume-skills-detail'),

    path('resumes/<int:resume_pk>/projects/', views.ProjectViewSet.as_view({
        'get': 'list',
        'post': 'create'
    }), name='resume-projects-list'),
    path('resumes/<int:resume_pk>/projects/<int:pk>/', views.ProjectViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'patch': 'partial_update',
        'delete': 'destroy'
    }), name='resume-projects-detail'),

    path('resumes/<int:resume_pk>/work-experience/', views.WorkExperienceViewSet.as_view({
        'get': 'list',
        'post': 'create'
    }), name='resume-work-experience-list'),
    path('resumes/<int:resume_pk>/work-experience/<int:pk>/', views.WorkExperienceViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'patch': 'partial_update',
        'delete': 'destroy'
    }), name='resume-work-experience-detail'),

    path('resumes/<int:resume_pk>/awards/', views.AwardViewSet.as_view({
        'get': 'list',
        'post': 'create'
    }), name='resume-awards-list'),
    path('resumes/<int:resume_pk>/awards/<int:pk>/', views.AwardViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'patch': 'partial_update',
        'delete': 'destroy'
    }), name='resume-awards-detail'),

    path('resumes/<int:resume_pk>/self-introduction/', views.SelfIntroductionViewSet.as_view({
        'get': 'list',
        'post': 'create'
    }), name='resume-self-introduction-list'),
    path('resumes/<int:resume_pk>/self-introduction/<int:pk>/', views.SelfIntroductionViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'patch': 'partial_update',
        'delete': 'destroy'
    }), name='resume-self-introduction-detail'),

    # 保留的功能性API
    path('resumes/<int:pk>/generate/', views.generate_resume, name='generate_resume'),
    path('resumes/<int:pk>/download-generated/', views.download_generated_resume, name='download_generated_resume'),
    path('resumes/<int:pk>/submit/', views.submit_resume, name='submit_resume'),
    path('resumes/<int:pk>/update-completion/', views.ResumeViewSet.as_view({'post': 'update_completion'}), name='update_completion'),

    # 简历审核功能
    path('resumes/<int:resume_id>/submit-for-review/', views.submit_resume_for_review, name='submit_resume_for_review'),
    path('resumes/<int:resume_id>/review-action/', views.review_resume_action, name='review_resume_action'),
    path('resumes/<int:resume_id>/versions/', views.get_resume_versions, name='get_resume_versions'),

    # 待审核简历列表
    path('pending-reviews/', views.get_pending_reviews, name='get_pending_reviews'),

    # 老师可访问的简历列表（包括已审批的）
    path('teacher/resumes/', views.get_teacher_resume_list, name='get_teacher_resume_list'),

    # 管理员端全局简历管理
    path('admin/all-resumes/', views.get_all_resumes, name='get_all_resumes'),
    path('admin/review-statistics/', views.get_review_statistics, name='get_review_statistics'),
    path('admin/resume-status-update/', views.update_resume_status, name='update_resume_status'),

    # 学生简历历史记录
    path('students/<int:student_id>/resume-history/', views.get_student_resume_history, name='get_student_resume_history'),

    # 代理服务简历文件（解决CORS问题）
    path('resumes/<int:resume_id>/file/', views.serve_resume_file_simple, name='serve_resume_file'),

    # 获取简历文件信息（用于预览）
    path('resumes/<int:resume_id>/file-info/', views.get_resume_file_info, name='get_resume_file_info'),

    # 模板生成简历
    path('generate-with-template/', views.generate_resume_with_template, name='generate_resume_with_template'),
]
